import Phaser from 'https://gitee.com/kiraking/ghl/raw/master/src/lib/phaser.js'

export default class Ending extends Phaser.Scene
{
    score

	score_text

    address

	end_sound
	button_sound

    end_bg

	share

	retry

    constructor()
	{
		super('ending')
	}

	init(data){

		this.score = data.score;

		this.address = data.address;

	}

	preload()
	{
		this.load.audio('end_sound', 'https://gitee.com/kiraking/ghl/raw/master/assets/sfx/end_sound.mp3')
		this.load.audio('button_sound', 'https://gitee.com/kiraking/ghl/raw/master/assets/sfx/button_sound.mp3')

		this.load.image('end_bg', this.address +'/end_bg.png')
		this.load.image('share', this.address +'/share.png')
		this.load.image('retry', this.address +'/retry.png')
	}

	create()
	{

		
		const { height, width } = this.game.config;

		this.end_sound = this.sound.add('end_sound', { volume: 0.2 });
		this.button_sound = this.sound.add('button_sound', { volume: 0.2 });

		this.end_sound.play();

		this.end_bg = this.add.image(width/2, height/2, 'end_bg').setScale(1.3);

		this.share = this.add.image(width/2 + 80, height/2 + 200, 'share')
		.setScale(1.2)
		.setInteractive();

		this.retry = this.add.image(width/2 - 80, height/2 + 200, 'retry')
		.setScale(1.2)
		.setInteractive();
		this.retry.on('pointerdown', () => { this.button_sound.play();this.scene.start('choose') })
	
		this.score_text = this.add
		.text(width / 2 + 8, height / 2 - 100, this.score, {fill: '#A6A6A6', fontSize:'56px', fontFamily:'Pixeled'})
		.setOrigin(0.5, 0.5);

	}


    update()
	{

    }
}